package com.laundry.controller;

import com.laundry.dto.ApiResponse;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/messages")
public class MessageController {
    
    @GetMapping("/unread-count")
    public ApiResponse<Map<String, Object>> getUnreadCount() {
        // 返回总的未读消息数量
        Map<String, Object> result = new HashMap<>();
        result.put("count", 0);
        return ApiResponse.success(result);
    }
    
    @GetMapping("/unread-counts")
    public ApiResponse<Map<String, Object>> getUnreadCounts() {
        // 返回按类型分组的未读消息数量
        Map<String, Object> result = new HashMap<>();
        result.put("system", 0);
        result.put("order", 0);
        result.put("activity", 0);
        result.put("service", 0);
        return ApiResponse.success(result);
    }
    
    @GetMapping("/stats")
    public ApiResponse<Map<String, Object>> getMessageStats() {
        // 返回消息统计信息
        Map<String, Object> result = new HashMap<>();
        result.put("total", 0);
        result.put("unread", 0);
        result.put("today", 0);
        return ApiResponse.success(result);
    }
    
    @GetMapping
    public ApiResponse<Map<String, Object>> getMessageList(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "20") int pageSize,
            @RequestParam(required = false) String type,
            @RequestParam(required = false) String keyword) {
        
        // 返回空的消息列表
        Map<String, Object> result = new HashMap<>();
        result.put("data", new Object[0]);
        result.put("total", 0);
        result.put("page", page);
        result.put("pageSize", pageSize);
        
        return ApiResponse.success(result);
    }
    
    @GetMapping("/{id}")
    public ApiResponse<Map<String, Object>> getMessageDetail(@PathVariable Long id) {
        // 返回消息详情（模拟数据）
        Map<String, Object> result = new HashMap<>();
        result.put("id", id);
        result.put("title", "系统消息");
        result.put("content", "这是一条系统消息");
        result.put("type", "system");
        result.put("isRead", false);
        result.put("createdAt", System.currentTimeMillis());
        
        return ApiResponse.success(result);
    }
    
    @PutMapping("/{id}/read")
    public ApiResponse<String> markAsRead(@PathVariable Long id) {
        return ApiResponse.success("消息已标记为已读");
    }
    
    @DeleteMapping("/{id}")
    public ApiResponse<String> deleteMessage(@PathVariable Long id) {
        return ApiResponse.success("消息已删除");
    }
    
    @PostMapping
    public ApiResponse<String> sendMessage(@RequestBody Map<String, Object> message) {
        return ApiResponse.success("消息发送成功");
    }
} 